<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>注册用户</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="/favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="http://light7.cn/dist/css/light7.css">
</head>
<body>
<div class="page-group">
    <div class="page page-current">
        <header class="bar bar-nav">
            <a class="button button-link button-nav pull-left external" href="#" onclick="goback()" data-transition='slide-out ' >
                <span class="icon icon-left"></span>
                返回
            </a>
            <h1 class="title">注册新用户</h1>
        </header>
        <div class="content">
            <div class="list-block">
            <ul>
                <li>
                    <div class="item-content">
                        <div class="item-media"><i class="icon icon-emoji"></i></div>
                        <div class="item-inner">
                            <div class="item-title label">昵称</div>
                            <div class="item-input">
                                <input type="email" id="nickName" name="nickName" placeholder="请输入你喜欢的昵称">
                            </div>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-content">
                        <div class="item-media"><i class="icon icon-phone"></i></div>
                        <div class="item-inner">
                            <div class="item-title label">手机号</div>
                            <div class="item-input">
                                <input type="email" id="userName" name="userName" placeholder="请输入登录手机号">
                            </div>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-content">
                        <div class="item-media"><i class="icon icon-settings"></i></div>
                        <div class="item-inner">
                            <div class="item-title label">密码</div>
                            <div class="item-input">
                                <input type="password" id="password" name="password" placeholder="请输入密码" class="">
                            </div>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-content">
                        <div class="item-media"><i class="icon icon-settings"></i></div>
                        <div class="item-inner">
                            <div class="item-title label">再次输入密码</div>
                            <div class="item-input">
                                <input type="text" id="passwordrep" name="passwordrep" placeholder="请再次输入密码" class="">
                            </div>
                        </div>
                    </div>
                </li>
            </ul>
            </div>
            <div class="content-block">
                <div class="row">
                    <div class="col-90">
                        <span id="errorSpn" name="errorSpn" style="color: red;font-size: 18px;"></span>
                    </div>
                </div>
                <div class="row">
                    <div class="col-100">
                        <a href="#" id="submitBtn" onclick="register();"  class="button button-big button-fill button-success">注册</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type='text/javascript' src='http://light7.cn/assets/js/jquery-2.1.4.js' charset='utf-8'></script>
<script type='text/javascript' src='http://light7.cn/dist/js/light7.js' charset='utf-8'></script>
<script>
    //注册
function  register() {
var  nickName=$("#nickName").val();
var userName=$("#userName").val();
var password=$("#password").val();
var passwordres=$("#passwordrep").val();
if(nickName==""){
    $("#errorSpn").text("请输入你喜欢的一个昵称！");
return false;
}
    if(userName==""){
        $("#errorSpn").text("请输入登陆手机号！");
        return false;
    }
    if(password==""){
        $("#errorSpn").text("请输入登陆密码！");
        return false;
    }
    if(passwordres==""){
        $("#errorSpn").text("请再次输入登陆密码！");
        return false;
    }else if(passwordres !=password){
        $("#errorSpn").text("两次输入的密码不一致！");
        return false;
    }else{
        $.ajax({
            type: "POST",//方法类型
            dataType: "json",
            url: "${ctx.getContextPath()}/register",
            data: {
                nickName:nickName,
                userName : userName,
                password : password
            },
            success: function (result) {
                if (result.code == 200) {
                    $("#errorSpn").text("注冊成功!");
                    location.href="/";
                }else{
                    var msg=result.message;
                    $("#errorSpn").text("ERROR："+msg);
                };
            },
            error : function() {
                alert("系统异常！");
            }
        });
    }
}
//返回上一步
function goback(){
    history.back();
}
</script>
</body>
</html>